﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Freebase4net.Tests.IntegrationTests
{
    [TestClass]
    public class SearchServiceTests
    {
        private SearchService _searchService;
        private string _searchTerm;
        public SearchServiceTests()
        {
            _searchService = FreebaseServices.CreateSearchService();
            _searchTerm = "tiger";
        }

        [TestMethod]
        public void Read_SimpleQuery_StatusCodeOk()
        {
            SearchServiceResponse result = _searchService.Read(_searchTerm);

            Assert.AreEqual(System.Net.HttpStatusCode.OK, result.Status);
        }

        [TestMethod]
        public async Task ReadAsync_SimpleQuery_StatusCodeOk()
        {
            SearchServiceResponse result = await _searchService.ReadAsync(_searchTerm);

            Assert.AreEqual(System.Net.HttpStatusCode.OK, result.Status);
        }

        [TestMethod]
        public async Task ReadAsync_LimitWith5_StatusCodeOk()
        {
            SearchServiceResponse result = await _searchService.ReadAsync(_searchTerm, limit: 5);

            Assert.AreEqual(5, result.Results.Count);
        }

        [TestMethod]
        public void Read_LimitWith5_StatusCodeOk()
        {
            SearchServiceResponse result = _searchService.Read(_searchTerm, limit: 5);

            Assert.AreEqual(5, result.Results.Count);
        }
        [TestMethod]
        public async Task ReadAsync_FilterByTypeAndDomain_StatusCodeOk()
        {
            SearchServiceResponse result = await _searchService.ReadAsync(_searchTerm, filter: "(any type:/music/recording domain:/film)");

            
            Assert.AreEqual(System.Net.HttpStatusCode.OK, result.Status);
        }


    }
}
